//
//  ExpertsViewController.m
//  InteriorDesign
//
//  Created by lanou on 15/12/16.
//  Copyright (c) 2015年 lanou. All rights reserved.
//

#import "ExpertsViewController.h"
#import "DesignerTableViewController1.h"
#import "DesignTableViewController2.h"
#import "EngineerTableViewController1.h"
#import "EngineerTableViewController2.h"
@interface ExpertsViewController ()

//分段控制器
@property (nonatomic, retain)UISegmentedControl *segementedControl;
@property (nonatomic, strong)DesignerTableViewController1 *design1;
@property (nonatomic, retain)DesignTableViewController2 *design2;
@property (nonatomic, retain)EngineerTableViewController1 *engineer1;
@property (nonatomic, retain)EngineerTableViewController2 *engineer2;

@property (nonatomic, assign)NSInteger *cellIndex;

@end

@implementation ExpertsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    //self.navigationController.navigationBarHidden = YES;
    //添加分段控制器
    self.segementedControl = [[UISegmentedControl alloc]initWithItems:@[@"找设计师",@"看设计作品",@"找工长",@"看施工项目"]];
    //设置属性
    self.segementedControl.frame = CGRectMake(45, 35, 290, 25);
    self.segementedControl.tintColor = [UIColor grayColor];
    self.segementedControl.selectedSegmentIndex = 0;
    //添加触发方法
    [self.segementedControl addTarget:self action:@selector(changeValueAction:) forControlEvents:(UIControlEventValueChanged)];
    [self.navigationController.view addSubview:self.segementedControl];
    
    
    self.design1 = [[DesignerTableViewController1 alloc]init];
    self.design2 = [[DesignTableViewController2 alloc]init];
    self.engineer1 = [[EngineerTableViewController1 alloc]init];
    self.engineer2 = [[EngineerTableViewController2 alloc]init];

    
    [self.view addSubview:self.design1.view];
    [self addChildViewController:self.design1];
    
    
    
}

//分段控件触发方法
- (void)changeValueAction:(UISegmentedControl *)segementedControl{
    switch (segementedControl.selectedSegmentIndex) {
        case 0:
            [self.view addSubview:self.design1.view];
            [self addChildViewController:self.design1];
            break;
        case 1:
            [self.view addSubview:self.design2.view];
            [self addChildViewController:self.design2];
            break;
        case 2:
            [self.design2.view removeFromSuperview];
            [self.design2 removeFromParentViewController];
            [self.view addSubview:self.engineer1.view];
            [self addChildViewController:self.engineer1];
            break;
        case 3:
            [self.engineer1.view removeFromSuperview];
            [self.engineer1 removeFromParentViewController];
            [self.view addSubview:self.engineer2.view];
            [self addChildViewController:self.engineer2];
       
            break;
        default:
            break;
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
